home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 5388 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.8 KB  |  78 lines

  1. Path: news.pi.net!news
  2. From: mv@pi.net
  3. Newsgroups: comp.lang.c
  4. Subject: ** Serial Number problem **
  5. Date: 12 Feb 1996 21:10:24 GMT
  6. Organization: IBM OS/2 Warp
  7. Message-ID: <4foac0$hq1@neptunus.pi.net>
  8. Reply-To: mv@pi.net
  9. NNTP-Posting-Host: asd46.pi.net
  10. X-Newsreader: IBM NewsReader/2 v1.03
  11.  
  12. Hello everybody,
  13.  
  14.  
  15. Please take a look at the following 'problem':
  16.  
  17.  
  18. The function below should say 'Ok !' when it has succesfully read a disks serial-number.
  19. As it shown below the function says 'No serial number !' which means that the carry-flag is
  20. set during the execution of the interrupt.
  21. This doesn't make any sense, but it gets even worse. if I leave out the 'char *no' declaration in
  22. the function prototype the function DOES work as it should...
  23.  
  24. ----------------------------------------------------------------------------
  25.  
  26. #include <stdio.h>
  27. #include <stdlib.h>
  28. #include <dos.h>
  29.  
  30.  
  31. void get_disk_serial(unsigned char disk, char *no)
  32.  
  33. {
  34.  union REGS regs;
  35.  struct SREGS seg;
  36.  
  37.     regs.x.ax=0x6900;
  38.     regs.h.bl=disk
  39.      segread(&seg);
  40.       intdosx(®s, ®s, &seg);
  41.        if (regs.x.cflag)
  42.         {
  43.          printf("No serial number !\n");
  44.         } else printf("Ok !\n");
  45. }
  46.  
  47.  
  48.  
  49. int main (void)
  50.  
  51.  
  52. {
  53.  char *s[10];
  54.  get_disk_serial(1,s);
  55.  return 0;
  56. }
  57.  
  58.  
  59. --------------------------------------------------------------------------------
  60.  
  61.  
  62. I've tried to figure out what is wrong here, but I just recently started programming in C after quitting
  63. with Turbo Pascal, but these things drive me nuts...
  64.  
  65. I've used the Snippets to help me underway, but I can't see the usefullnes of SEGREAD(), the
  66. Turbo C++ helpfunction and accompanying book don't tell that much....
  67. In my opinion you use this function to place the segment registers in a variable after a call to
  68. intdosx (or something like that), but it's prosition puzzles me...
  69.  
  70.  
  71. Could anybody please help ?
  72.  
  73.  
  74. TTYL,
  75.  
  76. Martijn :-)
  77.  
  78.